package com.daodai.hjcjsystem.eventListener;

import com.daodai.hjcjsystem.service.CollectionService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
@Component
public class StartCollect  {

    private final CollectionService collectionService;

    @EventListener(ApplicationReadyEvent.class)
    public void start(){
        // 这个方法会在应用完全启动并准备好接收请求时执行
        System.out.println(
               "  ____    _  _      ___     ___    _          _      ____  \n" +
                       " |___ \\  | || |    / _ \\   / _ \\  | |        / \\    | __ ) \n" +
                       "   __) | | || |_  | | | | | (_) | | |       / _ \\   |  _ \\ \n" +
                       "  / __/  |__   _| | |_| |  \\__, | | |___   / ___ \\  | |_) |\n" +
                       " |_____|    |_|    \\___/     /_/  |_____| /_/   \\_\\ |____/ \n" +
                       "                                                           "
        );
        //开始执行采集任务
        collectionService.batchCollection();
    }
}
